package com.database.dao.impl;

import java.util.List;

import javax.inject.Named;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Component;

import com.database.bean.Setting;
import com.database.dao.SettingDao;

@Named("settingDao")
@Component
public class SettingDaoImpl extends BaseDaoImpl<Setting> implements SettingDao {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public SettingDaoImpl() {
		super(Setting.class);
	}

	@Override
	public Setting getFirstSetting() {
		Session session = getSession();
		Query q=null;
		q=session.createQuery("FROM Setting AS N ORDER BY N.id ASC");
		@SuppressWarnings("unchecked")
		List<Setting> settings=q.list();
		
		closeSession();
		
		if(settings.size()>0){
			return settings.get(0);
		}
		else{
			return null;
		}
	}


}
